from app import db
from datetime import datetime

class Weight(db.Model):
    __tablename__ = 'weights'
    
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    weight = db.Column(db.Float, nullable=False)
    record_date = db.Column(db.Date, nullable=False)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    note = db.Column(db.String(200))
    
    user = db.relationship('User', backref=db.backref('weights', lazy='dynamic'))

    def __repr__(self):
        return f'<Weight {self.weight}kg on {self.record_date}>' 